/*******************************************************************************
* Project: QSAR(Cute Software Architecture) 
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: CanSM.c
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: CanSM
*
*******************************************************************************/

/** HEADER FILES **/
#include "CanSM.h"


/** MACRO DEFINITION **/


/** TYPEDEF DEFINITION **/


/** LOCAL DATA DECLARATION **/


/** GLOBAL DATA DECLARATION **/


/** LOCAL FUNCTION DECLARATION **/


/** GLOBAL FUNCTION DECLARATION **/

Std_ReturnType CanSM_RequestComMode(
    NetworkHandleType network, 
    ComM_ModeType ComM_Mode
);

Std_ReturnType CanSM_GetCurrentComMode(
    NetworkHandleType network, 
    ComM_ModeType* ComM_ModePtr
);

Std_ReturnType CanSM_StartWakeupSource(
    NetworkHandleType network
);

Std_ReturnType CanSM_StopWakeupSource(
    NetworkHandleType network
);

void CanSM_GetVersionInfo(
    Std_VersionInfoType* versionInfo
);

void CanSM_Init(
    const CanSM_ConfigType* ConfigPtr
);

void CanSM_MainFunction(
    void
);


/** LOCAL DATA **/


/** GLOBAL DATA **/


/** LOCAL FUNCTION **/


/** GLOBAL FUNCTION **/

/*******************************************************************************
* -Name         CanSM_RequestComMode
* -Brief        This service initializes the CanSM module
* -Details      None
* -Param[in]    network: Handle of destined communication network for request
* -Param[in]    ComM_Mode: Requested communication mode
* -Return       E_OK: Service accepted
*               E_NOT_OK: Service denied
*******************************************************************************/
Std_ReturnType CanSM_RequestComMode(
    NetworkHandleType network, 
    ComM_ModeType ComM_Mode
)
{
    switch(ComM_Mode)
    {
        case COMM_NO_COMMUNICATION:
        {
            CanIf_SetControllerMode(0u, CAN_CS_STOPPED);
            break;
        }
        case COMM_SILENT_COMMUNICATION:
        {
            CanIf_SetControllerMode(0u, CAN_CS_STOPPED);
            break;
        }
        case COMM_FULL_COMMUNICATION:
        {
            CanIf_SetControllerMode(0u, CAN_CS_STARTED);
            break;
        }
        case COMM_FULL_COMMUNICATION_WITH_WAKEUP_REQUEST:
        {
            break;
        }
        default:
        {
            break;
        }
    }
}

/*******************************************************************************
* -Name         CanSM_GetCurrentComMode
* -Brief        This service shall put out the current communication mode of a CAN network
* -Details      None
* -Param[in]    network: Network handle, whose current communication mode shall be put out
* -Param[out]   ComM_ModePtr: Pointer, where to put out the current communication mode
* -Return       E_OK: Service accepted
*               E_NOT_OK: Service denied
*******************************************************************************/
Std_ReturnType CanSM_GetCurrentComMode(
    NetworkHandleType network, 
    ComM_ModeType* ComM_ModePtr
)
{
    
}

/*******************************************************************************
* -Name         CanSM_StartWakeupSource
* -Brief        This function shall be called by EcuM when a wakeup source shall be started
* -Details      None
* -Param[in]    network: Affected CAN network
* -Return       E_OK: Request accepted
*               E_NOT_OK: Request denied
*******************************************************************************/
Std_ReturnType CanSM_StartWakeupSource(
    NetworkHandleType network
)
{
    
}

/*******************************************************************************
* -Name         CanSM_StopWakeupSource
* -Brief        This function shall be called by EcuM when a wakeup source shall be stopped
* -Details      None
* -Param[in]    network: Affected CAN network
* -Return       E_OK: Request accepted
*               E_NOT_OK: Request denied
*******************************************************************************/
Std_ReturnType CanSM_StopWakeupSource(
    NetworkHandleType network
)
{
    
}



/*******************************************************************************
* -Name         CanSM_GetVersionInfo
* -Brief        Returns the version information of this module 
* -Details      None
* -Param[out]   versioninfo: Pointer to the version information of this module
* -Return       None          
*******************************************************************************/
void CanSM_GetVersionInfo(
    Std_VersionInfoType* versionInfo
)
{
    versionInfo->vendorID = (uint16)YSAR_VENDOR_ID;
    versionInfo->moduleID = (uint8)CANSM_MODULE_ID;
    versionInfo->sw_major_version = (uint8)CANSM_SW_MAJOR_VERSION;
    versionInfo->sw_minor_version = (uint8)CANSM_SW_MINOR_VERSION;
    versionInfo->sw_patch_version = (uint8)CANSM_SW_PATCH_VERSION;
}

/*******************************************************************************
* -Name         CanSM_Init
* -Brief        This service initializes the CanSM module
* -Details      None
* -Param[in]    ConfigPtr: Pointer to init structure for the post build parameters of the CanSM
* -Return       None          
*******************************************************************************/
void CanSM_Init(
    const CanSM_ConfigType* ConfigPtr
)
{
    CanIf_SetControllerMode(0u, CAN_CS_STOPPED);
}

/*******************************************************************************
* -Name         CanSM_MainFunction
* -Brief        Scheduled function of the CanSM
* -Details      None
* -Param[in]    None
* -Return       None          
*******************************************************************************/
void CanSM_MainFunction(
    void
)
{
    
}

